<template>
  <div class="temp shou" @click.prevent="toDetail(item)">
    <div class="rela flex coverBox">
      <img class="cover" :src="item.coursePic" alt="加载失败" />
      <img
        :src="require(`@/assets/images/status${item.status}.png`)"
        class="coverTip absolute"
        alt="加载失败"
      />
    </div>
    <div class="nameBox flexBet">
      <div class="name overTxt">{{ item.courseName }}</div>
    </div>
    <div class="infobox flex">
      <div class="wname overTxt">{{ item.workstationNames }}</div>
    </div>
    <reject :open.sync="rejectOpen" :item="rejectItem" :type="3"></reject>
    <addStudent :open.sync="addStudentOpen" :courseId="courseId"></addStudent>
  </div>
</template>

<script>
import addStudent from "@/views/tea_course/components/addStudent.vue";
import reject from "@/components/reject.vue";
export default {
  components: { reject, addStudent },
  props: {
    item: Object,
    type: String,
  },
  data() {
    return {
      addStudentOpen: false,
      rejectOpen: false,
      rejectItem: {},
      courseId: 0,
    };
  },
  methods: {
    /* 启用 停用课程 */
    courseStatus(item, status) {
      this.$confirm(
        `是否确认${status == 0 ? "启用" : "停用"}工作站?${
          status == 0 ? "" : "停用后课程将无法关联工作站"
        }`,
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(async () => {
          let data = JSON.parse(JSON.stringify(item));
          data.status = status;
          await updatePost_course(data);
          this.$modal.msgSuccess(`${status == 0 ? "启用" : "停用"}成功`);
          this.$emit("refresh", true);
          this.$refs["popoverName"].doClose();
        })
        .catch(() => {});
    },

    // 跳转
    toDetail(item) {
      console.log(item, this.type);
      this.$router.push({
        path: "/course/add",
        query: {
          type: "detail",
          courseId: item.courseId,
          modelType: item.courseTemplate,
        },
      });
    },
  },
  created() {},
  mounted() {},
};
</script>
<style scoped lang='scss'>
.showContent {
  margin: 7px 0 0 0;
  width: 17px;
  height: 10px;
  background-size: 17px 10px;
  background-image: url("../assets/images/more1.png");
}

.showContent:hover {
  background-image: url("../assets/images/more2.png");
}

.hideContent {
  img {
    margin: auto 21px auto 24px;
    width: 15px;
    height: 15px;
  }

  .ctemp {
    font-size: 14px;
    color: #666666;
    line-height: 36px;
    height: 36px;
    border-bottom: 1px solid #edeff0;
  }

  .ctemp:hover {
    background: #f5f5f5;
  }
}

.temp:hover {
  box-shadow: 0 0 20px 0 rgba(0, 55, 50, 0.12);
}

.temp {
  margin: 0 32px 42px 0;
  width: 240px;
  height: 217px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #ebebeb;

  .coverBox {
    margin: 12px 0 0 12px;
    width: 216px;
    height: 135px;
  }

  .cover {
    width: 216px;
    height: 135px;
    background: #f7f7f8;
    border-radius: 8px;
  }

  .coverTip {
    z-index: 3;
    top: 4px;
    left: -20px;
    width: 56px;
    height: 29px;
  }

  .nameBox {
    margin: 8px 0 0 12px;
    width: 210px;
    font-size: 16px;
    color: #333333;
    line-height: 22px;

    .name {
      width: 180px;
    }
  }

  .infobox {
    margin-top: 8px;
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC, sans-serif;
    font-weight: 400;
    color: #999999;
    line-height: 20px;

    .credit {
      margin-left: 12px;
    }

    .wname {
      width: 220px;
      margin-left: 10px;
    }
  }
}
</style>
